#include <stdio.h>
#include <string>
#include <iostream>
#include "SqStack.h"
#include "SqQueue.h"

using namespace std;

bool isLeft(char c){
    return c == '(' || c == '[' || c == '{';
}
bool isMatch(char left, char right){
    if(left == '('){
        return right == ')';
    }else if(left == '['){
        return right == ']';
    }else{
        return right == '}';
    }
}
bool isLegalParenthesis(string s){
    SqStack stack;
    init(stack);
    char ele;
    for(int i = 0; i < s.length(); i++){
        if(isLeft(s[i])){
            push(stack, s[i]);
        }else{
            pop(stack, ele);
            if(!isMatch(ele, s[i])){
                return false;
            }
        }
    }
    return isEmpty(stack);
} 
void question1(){
    string s;
    cout<<"输入字符串:"<<endl;
    cin>>s;
    if(isLegalParenthesis(s)){
        printf("true");
    }else{
        printf("false");
    }
}

void questionn2(){
    SqQueue Q;
    init(Q);
    //添加10个，只能容纳九个
    printf("-----队满入队情况-----\n");
    for(int i = 0; i < 10; i++){
        if(!enter(Q, i + 1)){
            printf("队满!\n");
        }
    }
    printQueue(Q);
    printf("\n");
    //出队2个
    printf("------出队-----\n");
    int e;
    for(int i = 0; i < 2; i++){
        remove(Q, e);
    }
    printQueue(Q);
    printf("\n");
    //入队两个
    printf("-----入队-----\n");
    for(int i = 10; i < 12; i++){
        enter(Q, i);
    }
    printQueue(Q);
    printf("\n");
    //出队11个，只有9个
    printf("-----空队出队情况-----\n");
    for(int i = 0; i < 11; i++){
        if(!remove(Q, e)){
            printf("队空!\n");
        }
    }
    printQueue(Q);
    printf("\n");
}

int main(){
    // question1();
    questionn2();
    return 0;
}